using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace MyMvc.Model.Models.Mapping
{
    public class ArticleMap : EntityTypeConfiguration<Article>
    {
        public ArticleMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Title)
                .IsRequired()
                .HasMaxLength(1024);

            this.Property(t => t.Author)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("Article");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.CreateDateTime).HasColumnName("CreateDateTime");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.SubCategory).HasColumnName("SubCategory");
            this.Property(t => t.Content1).HasColumnName("Content1");
            this.Property(t => t.Count).HasColumnName("Count");
            this.Property(t => t.Author).HasColumnName("Author");
        }
    }
}
